<template>
	<view class="content">
		<view class="header">
			<view :class="['header_list',{currentNav:currIndex == item.type}]" v-for="(item,index) in headerList" :key="index" 
			@click="tapNav(item)">{{item.name}}</view>
		</view>
		<view class="group">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">	
				<view class="evaluate_cont" v-for="(item,index) in evaluateList" :key="index">
					<view class="evaluate_cont_top">
						<view class="evaluate_fl">
							<view class="avatar">
								<image class="avatar_img" :src="item.avatar" mode=""></image>
							</view>
							<view class="avatar_info">
								<view class="user_name ellipsis">{{item.nickname}}</view>
								<view class="user_star">
									<tui-rate :current="item.productScore" normal="#DBDBDB" active="#C7973B" :size="14"></tui-rate>
								</view>
							</view>
						</view>
						<view class="evaluate_date">{{item.createTime.split(" ")[0]}}</view>
					</view>
					<view class="specification">
						<text>{{item.sku}}</text>
					</view>
					<view class="specification_cont">{{item.merchantReplyContent}}</view>
					<!--  v-if="reply.picturesArr.length != 0" -->
					<view class="specification_pic">
						<view class="pic_list" v-for="(litem,lindex) in item.picturesArr" :key="lindex">
							<image class="evaluate_image" :src="litem" mode="aspectFill"></image>
						</view>
					</view>
					
				</view>
				
			</mescroll-body>
		</view>
		
		
		
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				headerList:[{type:1,name:'好评'},{type:2,name:'中评'},{type:3,name:'差评'}],
				currIndex:1,
				downOption: {
					auto: true //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption: {
					auto: true, // 不自动加载
					// page: {
					// 	num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
					// 	size: 10 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty: {
						tip: '~ 空空如也 ~', // 提示
						btnText: '刷新',
						// 列表第一页无任何数据时,显示的空布局
						// use : 是否启用
						// icon : 空布局的图标路径 (支持网络路径)
						// tip : 提示文本
						// btnText : 按钮文本
						// fixed : 是否使用定位,默认false; 配置fixed为true,以下的top和zIndex才生效 (transform会使fixed失效,所以最终还是会降级为absolute)
						// top : fixed定位的top值 (完整的单位值,如"100rpx", "10%";)
						// zIndex : fixed定位z-index值
					},
					textNoMore: "--我也是有底线的--" //没有更多数据的提示文本
				},
				evaluateList:[],
				id:'' // 商品id
				
			}
		},
		onLoad(options) {
			console.log(options)
			if (Object.keys(options).length != 0) {
				this.id = options.id
			}
		},
		methods: {
			// 评价切换
			tapNav: function (item) {
				this.currIndex = item.type
				this.mescroll.resetUpScroll(); //调用加载
			},
			// 获取列表
			downCallback(){
				this.mescroll.resetUpScroll(); //调用加载
			},
			upCallback(page) {
				//联网加载数据
				// console.log(page)
				let that = this;
				that.api.integralEvaluate(that.id,{
					page:page.num,
					limit:page.size,
					type:that.currIndex
				}).then(res => {
					console.log(res)
					
					let curPageData =res.data.records;
					// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
					let curPageLen = curPageData.length;
					// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
					let totalPage = res.data.pages;
					//设置列表数据
					setTimeout(() => { // 模拟效果
						if (page.num == 1) this.evaluateList = []; //如果是第一页需手动置空列表
						this.evaluateList = this.evaluateList.concat(curPageData); //追加新数据
						console.log(this.evaluateList,"---------");
						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);
					}, 500)
					
				})
				
			},
			
			
			
		}
	}
</script>

<style lang="less">
	page {
		width: 100%;
		box-sizing: border-box;
		letter-spacing: 3rpx;
		font-size: 28rpx;
		color: #333333;
		background: #FFFFFF;
		padding: 0 39rpx;
	}
	.content {
		width: 100%;
		box-sizing: border-box;
	}
	.header {
		width: 100%;
		box-sizing: border-box;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		.header_list {
			width: 124rpx;
			height: 48rpx;
			line-height: 48rpx;
			text-align: center;
			border: 1rpx solid #999999;
			border-radius: 24rpx;
			color: #666666;
			margin-right: 28rpx;
			&.currentNav {
				border: 1rpx solid #E42221;
				color: #E42221;
			}
		}
	}
	.group {
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx 0;
		.evaluate_cont {
			width: 100%;
			box-sizing: border-box;
			padding-top: 30rpx;
			.evaluate_cont_top {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 26rpx;
				color: #140005;
				.evaluate_date {
					width: 180rpx;
					color: #999999;
					font-size: 22rpx;
					text-align: right;
				}
				.evaluate_fl {
					width: calc(100% - 180rpx);
					box-sizing: border-box;
					padding-right: 10rpx;
					display: flex;
					justify-content: flex-start;
					// align-items: center;
					.avatar {
						width: 72rpx;
						height: 72rpx;
						.avatar_img {
							width: 100%;
							height: 100%;
							border-radius: 50%;
						}
					}
					.avatar_info {
						width: calc(100% - 72rpx);
						box-sizing: border-box;
						padding-left: 16rpx;
						display: flex;
						flex-flow: column;
						justify-content: space-between;
						
					}
					
					
				}
				
				
			}
			.specification {
				width: 100%;
				box-sizing: border-box;
				line-height: 60rpx;
				font-size: 22rpx;
				color: #999999;
				margin: 16rpx 0;
				text {
					padding: 0 20rpx;
					background: #F0F0F0;
					border-radius: 4rpx;
				}
			}
			.specification_cont {
				width: 100%;
				box-sizing: border-box;
				font-size: 26rpx;
				color: #140005;
				line-height: 44rpx;
			}
			.specification_pic {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				flex-flow: wrap;
				padding: 20rpx 0;
				.pic_list {
					width: 171rpx;
					height: 162rpx;
					margin-right: 24rpx;
					margin-bottom: 20rpx;
					.evaluate_image {
						width: 100%;
						height: 100%;
						border-radius: 16rpx;
					}
				}
				
			}
			
			
			
		}
			
		
		
		
		
		
	}
	
	
	
	

</style>
